home *** CD-ROM | disk | FTP | other *** search
- /************************************************************************************************/
- /* */
- /* Module Name: Alert */
- /* */
- /* File Name: Alert.c */
- /* */
- /* © Apple Computer, Inc. 1991-1995 */
- /* All Rights Reserved */
- /* */
- /* Revision History: */
- /* */
- /* Date Who Modification */
- /* */
- /* 1991-08-14 Chris Halim Original version */
- /* 1995-06-26 Jaakko Railo Version 2.0 */
- /* */
- /************************************************************************************************/
-
- /****************************************** DESCRIPTION ******************************************
-
- *************************************************************************************************/
-
- /******************************************** HEADERS *******************************************/
-
- #include "TextUtils.h"
-
- #include "TestModule.h"
-
- /****************************************** DEFINITIONS *****************************************/
-
- #define rGetTwoNumbersDLOG 10000
- #define kNumber1 3
- #define kNumber2 5
-
- /****************************************** PROTOTYPES ******************************************/
-
- short GetTwoNumbers (short * , short *);
- void DoTest (CHRSPtr paramPtr);
-
- /************************************************************************************************/
- /************************************************************************************************/
-
-
- pascal short TestModule (CHRSPtr paramPtr)
- {
- short returnValue = noErr;
-
- if (paramPtr->version <= kTestModuleVersion) {
-
- DoTest (paramPtr);
-
- }
- else
- returnValue = kWrongVersion;
-
- return (returnValue);
- }
-
-
- short GetTwoNumbers (short * number1, short * number2)
- {
- short itemKind;
- Handle itemHand;
- Rect itemRect;
- short itemHit;
- DialogPtr theDialog;
- Str255 itemStr;
- long tlong;
-
- if ((theDialog = GetNewDialog (rGetTwoNumbersDLOG, nil, (WindowPtr)(-1L))) != nil) {
- GetDItem (theDialog, kNumber1, &itemKind, &itemHand, &itemRect);
- SelIText (theDialog, kNumber1, 0, 32767);
-
- ShowWindow (theDialog);
-
- ModalDialog (nil, &itemHit);
-
- if (itemHit == ok) {
- GetDItem (theDialog, kNumber1, &itemKind, &itemHand, &itemRect);
- GetIText (itemHand, itemStr);
- StringToNum (itemStr, &tlong);
- *number1 = tlong;
-
- GetDItem (theDialog, kNumber2, &itemKind, &itemHand, &itemRect);
- GetIText (itemHand, itemStr);
- StringToNum (itemStr, &tlong);
- *number2 = tlong;
- }
-
- DisposeDialog (theDialog);
- }
- else
- itemHit = -1;
-
- return (itemHit);
- }
-
-
- void DoTest (CHRSPtr paramPtr)
- {
- TELHandle termHand = GetCurrentTELHandle (paramPtr);
- short itemHit;
- OSErr errCode;
- short level, pattern;
-
- if ((itemHit = GetTwoNumbers (&level, &pattern)) == ok) {
-
- if ((errCode = TELAlert (termHand, &level, pattern)) == noErr)
- Print (paramPtr, "TELAlert --> level = %d", level);
- else
- Print (paramPtr, "### TELAlert failed : %d", errCode);
- }
- else
- if (itemHit == -1)
- Print (paramPtr, "### Unable to get a DLOG resource");
- }
-
-
-